package com.ljxt.dt.web.servlet.storemanagementservlet;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.ljxt.dt.service.storemanagementservice.IsdeleteService;
import com.ljxt.dt.service.storemanagementservice.impl.IsDeleteServiceImpl;
import com.ljxt.dt.util.ServiceUtil;
import com.ljxt.dt.util.ServletUtil;

import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 唐春劲
 * @version 1.0.0
 * @date 2020-05-21 9:54
 * @copyright 老九学堂
 */
@WebServlet("/isDelete")
public class IsDelete extends HttpServlet {
    private IsdeleteService admin = new IsDeleteServiceImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doGet(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //判断是否能够删除供应商里的商品
        Integer id = ServletUtil.getQueryInt(req,"id");

        boolean isTrue = admin.isTrue(id);
        ObjectMapper objectMapper = new ObjectMapper();
        resp.getWriter().write(objectMapper.writeValueAsString(isTrue));
    }
}
